<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="service.ErrorService" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<% ErrorService error = (ErrorService) request.getAttribute("error"); %>

<html>
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<style type="text/css"></style>
</head>
	<body>
	
		<div class="container">
		<div class="header">
			<ul class="nav nav-pills pull-right">
				<li><a href="Logout">Log Out</a></li>
			</ul>
			<h2 class="text-muted">Tournament Hosting</h2>
			<hr>
		</div>
	</div>
	<h3>Admin Site</h3>
	<%
			if (error != null) {
				out.print("<div class=\"col-md-4 well\" id=\"content\">");
				out.println(error.getError());
				out.print("</div>");
			}	
	%>
	
	<div class="col-md-6 list-group">
	<h2 class="text-muted">Team Control</h2>
	${teamList}
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#createteamModal">Create Team</button>
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addmemberModal">Add Member</button>
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#removememberModal">Remove Member</button>
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#editteamModal">Edit Team</button>
		<button class="btn btn-warning btn-lg" data-toggle="modal" data-target="#deleteteamModal">Delete Team</button>
		<br>
	</div>
	
	<div class="col-md-6 list-group">
	<h2 class="text-muted">Tournament Control</h2>
	${tournList}
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#createtourModal">Create Tournament</button>
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addteamModal">Add Team</button>
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#removeteamModal">Remove Team</button>
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#edittourModal">Edit Tournament</button>
		<button class="btn btn-warning btn-lg" data-toggle="modal" data-target="#deletetourModal">Delete Tournament</button>
		<br>
	</div>
	
	<div class="col-md-6 list-group">
	<h2 class="text-muted">User Control</h2>
	${userList}
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#createuserModal">Create User</button>
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#edituserModal">Edit User</button>
		<button class="btn btn-warning btn-lg" data-toggle="modal" data-target="#deleteuserModal">Delete User</button>
		<br>
	</div>
	
	<!-- Modal -->
	<div class="modal fade" id="createteamModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Create Team</h4>
      			</div>
				<div class="modal-body">
						<form method="POST" action="Admin" >
            				<h2 class="form-signin-heading">Create New Team</h2>
                			<label> Team Name</label>
                			<input type="text" class="form-control" name="team_name" placeholder="Team Name" autofocus="">
              				<br>
            				<label>Sport</label>
              				<select class="form-control" name="Sport">
                			<option value="" disabled selected>Please select a sport</option>
                			<option value="soccer">Soccer</option>
              			    <option value="tennis">Tennis</option>
                			<option value="pool">Pool</option>
                			</select>        
              				<br>
              				<label>Team Leader</label>
              				<input type="text" class="form-control" name="teamLeader" placeholder="Username">
              				<br>
              				<input type="hidden" name="action" value="create team">
                			<button class="btn btn-lg btn-primary " type="submit">Create</button> 	
						</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- Modal -->
	
	<!-- Modal -->
	<div class="modal fade" id="addmemberModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Add Member</h4>
      			</div>
				<div class="modal-body">
					<form method="POST" action="Admin" >
						<label>Team name</label>
						<input class="form-control" type="text" name="team_name">
						<br>
						<label>Username</label>
						<input class="form-control" type="text" name="user">
						<br>
						<input type="hidden" name="action" value="add member">
						<button type="submit" class="btn btn-lg btn-primary" >Add User</button>		
					</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- Modal -->
	
	<div class="modal fade" id="removememberModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Remove Member</h4>
      			</div>
				<div class="modal-body">
					<form method="POST" action="Admin" >
						<label>Team name</label>
						<input class="form-control" type="text" name="team_name">
						<br>
						<label>Team name</label>
						<input class="form-control" type="text" name="user">
						<br>
						<input type="hidden" name="action" value="remove member">
						<button type="submit" class="btn btn-lg btn-primary" >Remove Member</button>	
					</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- Modal -->

	<div class="modal fade" id="editteamModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Edit Team</h4>
      			</div>
				<div class="modal-body">
					<form method="POST" action="Admin">
	                	<label>Team To Change</label>
	                	<input type="text" class="form-control" name="oTeam_name">
	                	
	              		<br>
	                	<label> Team Name</label>
	                	<input type="text" class="form-control" name="team_name">
	              		<input type="hidden" class="form-control" name="action" value="edit team">
						
	              		<br>
	            		<label>Sport</label>
	             	   	<select class="form-control" name="Sport">
	            	    <option value="" disabled selected>Please select a sport</option>
	            	    <option value="soccer">Soccer</option>
	          	      	<option value="tennis">Tennis</option>
	           	     	<option value="pool">Pool</option>
	           	     	</select>  
	           	     	
	           	     	<br>
	           	     	<label>Team Leader</label>
	                	<input type="text" class="form-control" name="teamLeader">
	           	     	
	                	      
	              		<br>
	                	<button class="btn btn-lg btn-primary " type="submit">Edit</button> 	
					</form>
	      		</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
<!-- Modal -->
	
	<div class="modal fade" id="deleteteamModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Delete Team</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin">
                		<label>Team name</label>
						<input class="form-control" type="text" name="team_name">
						<br>
						<input type="hidden" name="action" value="delete team">
						<button type="submit" class="btn btn-lg btn-primary" >Delete Team</button>							
        			</form>
	      		</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
<!-- Modal -->
	
		<!-- Modal -->
	<div class="modal fade" id="createtourModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Create New Team</h4>
      			</div>
				<div class="modal-body">
					<form method="POST" action="Admin" >
						<label>Tournament Name</label>
                			<input type="text" class="form-control" name="tournament_name" autofocus="">
                			<br>
                		<label>Sport</label>
                			<select class="form-control" name="Sport">
                    		<option value="" disabled selected>Please select a sport</option>
                        	<option value="soccer">Soccer</option>
                        	<option value="tennis">Tennis</option>
                        	<option value="pool">Pool</option>
                    		</select>
                			<br>
                		<label>Tournament Format</label>
                			<select class="form-control" name="Tournament Format">
                    		<option value="" disabled selected>Please select a format</option>
                        	<option value="format1">Single Elimination</option>
                        	<option value="format2">Double Elimination</option>
                    		</select>
                			<br>
                		<label>Tournament Type</label>
                			<select class="form-control" name="Tournament Type">
                    		<option value="" disabled selected>Please select a type</option>
                        	<option value="type1">Open</option>
                        	<option value="type2">Invitation</option>
                    		</select>
                			<br>
                		<label>Participant Count</label>
                			<input type="text" class="form-control" name="size">
                			<br>
                		<label>Starting Date</label>
                			<input type="text" class="form-control" name="Starting Date">
                			<br>
                		<label>Info</label>
                			<input type="text" class="form-control" name="info">
                			<br>
                		<label>Organizer Username</label>
                			<input type="text" class="form-control" name="organizer">
                			<br>
                			<input type="hidden" name="action" value="create tour">		
							<button type="submit" class="btn btn-lg btn-primary" >Create</button>
					</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- Modal -->
	
	<!-- Modal -->
	<div class="modal fade" id="addteamModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Add Team</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin" >
						<label>Team name</label>
						<input class="form-control" type="text" name="team_name">
						<br>
						<label>Tournament name</label>
						<input class="form-control" type="text" name="tour_name">
						<br>
						<input type="hidden" name="action" value="add team">
						<button type="submit" class="btn btn-lg btn-primary" >Add Team</button>								
					</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- Modal -->
	
	<div class="modal fade" id="removeteamModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Remove Team</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin" >
						<label>Team name</label>
						<input class="form-control" type="text" name="team_name">
						<br>
						<label>Tournament name</label>
						<input class="form-control" type="text" name="tour_name">
						<br>
						<input type="hidden" name="action" value="remove team">
						<button type="submit" class="btn btn-lg btn-primary" >Remove Team</button>									
					</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- Modal -->

	<div class="modal fade" id="edittourModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Edit Tournament</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin" >						
						<label>Tournament Name</label>
                			<input type="text" class="form-control" name="oTournament_name" autofocus="">
                			<br>						
						<label>New Tournament Name</label>
                			<input type="text" class="form-control" name="tournament_name" autofocus="">
                			<br>
                		<label>New Sport</label>
                			<select class="form-control" name="Sport">
                    		<option value="" disabled selected>Please select a sport</option>
                        	<option value="soccer">Soccer</option>
                        	<option value="tennis">Tennis</option>
                        	<option value="pool">Pool</option>
                    		</select>
                			<br>
                		<label>New Tournament Format</label>
                			<select class="form-control" name="Tournament Format">
                    		<option value="" disabled selected>Please select a format</option>
                        	<option value="format1">Single Elimination</option>
                        	<option value="format2">Double Elimination</option>
                    		</select>
                			<br>
                		<label>New Tournament Type</label>
                			<select class="form-control" name="Tournament Type">
                    		<option value="" disabled selected>Please select a type</option>
                        	<option value="type1">Open</option>
                        	<option value="type2">Invitation</option>
                    		</select>
                			<br>
                		<label>New Participant Count</label>
                			<input type="text" class="form-control" name="size">
                			<br>
                		<label>New Starting Date</label>
                			<input type="text" class="form-control" name="Starting Date">
                			<br>
                		<label>New Info</label>
                			<input type="text" class="form-control" name="info">
                			<br>
                		<label>Organizer Username</label>
                			<input type="text" class="form-control" name="organizer">
                			<br>
                			<input type="hidden" name="action" value="edit tour">		
							<button type="submit" class="btn btn-lg btn-primary" >Edit</button>
						
					</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
<!-- Modal -->
	
	<div class="modal fade" id="deletetourModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Delete Tournament</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin">
                		<label>Tournament name</label>
						<input class="form-control" type="text" name="tour_name">
						<br>
						<input type="hidden" name="action" value="delete tour">
						<button type="submit" class="btn btn-lg btn-primary" >Delete Tournament</button>							
        			</form>
	      		</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
<!-- Modal -->

	<!-- Modal -->
	<div class="modal fade" id="createuserModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Create User</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin" >
						<label>Email address</label>
       						<input type="email" class="form-control" autofocus="" name="email">
        				<label>Username</label>
        					<input class="form-control" type="text" name="username">
        				<label>Password</label>
        					<input type="password" class="form-control" name="password">
        					<br>
        				<input type="hidden" name="action" value="create user">
						<button type="submit" class="btn btn-lg btn-primary" >Create User</button>							
        			</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- Modal -->
	

	<div class="modal fade" id="edituserModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Edit User</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin" >
						<label>User To Change</label>
       						<input class="form-control" type="text" autofocus="" name="usern"> 										
						<label>New Email address</label>
       						<input type="email" class="form-control" name="email">
        				<label>New Username</label>
        					<input type="text" class="form-control" name="username">
        				<label>New Password</label>
        					<input type="password" class="form-control" name="password">
        					<br>
        				<input type="hidden" name="action" value="edit user">
						<button type="submit" class="btn btn-lg btn-primary" >Edit</button>		
					</form>
				</div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
<!-- Modal -->
	
	<div class="modal fade" id="deleteuserModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        			<h4 class="modal-title">Delete User</h4>
      			</div>
				<div class="modal-body">
					<form class="form-signin" method="POST" action="Admin">
                		<label>Username</label>
						<input class="form-control" type="text" name="username">
						<br>
						<input type="hidden" name="action" value="delete user">
						<button type="submit" class="btn btn-lg btn-primary" >Delete</button>							
					</form>
	      		</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
<!-- Modal -->

</body>
		
</html>